package hihocoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;

/**
 * 
 */

/**
 * @author zhongfang
 *
 */
public class FindMax {

	static class Point implements Comparable<Point>{
		int x;
		int y;
		public Point(int x,int y) {
			this.x=x;
			this.y=y;
		}
		
		@Override
		public boolean equals(Object obj) {
			Point oth=(Point)obj;
			return this.x==oth.x&&this.y==oth.y;
		}

		@Override
		public int compareTo(Point o) {
			return this.x*this.y*(x&y)-o.x*o.y*(o.x&o.y);
		}
		
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int T=scanner.nextInt();
		for (int i = 0; i < T; i++) {
			int N=scanner.nextInt();
			ArrayList<Integer> list=new ArrayList<>();
		 	//int[] A=new int[N];
			for(int j=0;j<N;j++){
				//A[j]=scanner.nextInt();
				list.add(scanner.nextInt());
			}
			long result=0;
//			for (int j = 0; j < A.length-1; j++) {
//				for (int k2 = j+1; k2 < A.length; k2++) {//任意两个数之间
//					int andRes=(A[j]&A[k2]);
//					if(andRes==0)
//						continue;
//					long curResult=(long)A[j]*A[k2];
//					curResult*=andRes;
//					if(curResult>result){
//						result=curResult;
//					}
//				}
//			}
			//直接返回最大的两个数
//			Collections.sort(list);
			ArrayList<Point> points=new ArrayList<>();
			for (int j = 0; j < list.size()-1; j++) {
				for (int j2 = j+1; j2 < list.size(); j2++) {
					Point point=new Point(list.get(j), list.get(j2));
					points.add(point);
				}
			}
			Collections.sort(points);
//			int x=list.get(N-2);
//			int y=list.get(N-1);
			int x=points.get(N-1).x;
			int y=points.get(N-1).y;
			result=(long)x*y;
			result*=x&y;
			System.out.println(result);
		}
	}

}
